package fr.resasante.spring3.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import fr.resasante.spring3.controller.common.ControllerAbstract;

/**
 * Controller for displaying the login page
 * 
 * @author GEFFROY-DE-VILLEBLAN
 * 
 */
@Controller
public class LoginController extends ControllerAbstract {
	/**
	 * Displays the login form
	 * 
	 * @param model
	 *            The model
	 * @return The view of the login form
	 */
	@RequestMapping(value = "/login", method = RequestMethod.GET)
	public String showLogin(ModelMap model) {
		return "login";
	}

	/**
	 * Displays the login form with an error
	 * 
	 * @param model
	 *            The model
	 * @return The view of the login form
	 */
	@RequestMapping(value = "/loginFailed", method = RequestMethod.GET)
	public String showLoginError(ModelMap model) {
		model.addAttribute("error", "true");
		return "login";
	}

	/**
	 * Displays the login form after a logout
	 * 
	 * @param model
	 *            The model
	 * @return The view of the login form
	 */
	@RequestMapping(value = "/logout", method = RequestMethod.GET)
	public String showLogout(ModelMap model) {
		return "login";

	}
}
